<template>
  <div class="home">
    <img alt="iconUrl" :src="iconUrl">
    <Home :msg="msg"/>
    <el-button type="primary" @click="logout">退出登录</el-button>
  </div>
</template>

<script>
// @ is an alias to /src
import Home from '@/components/Home.vue'

export default {
  name: 'HomeView',
  components: {
    Home
  },
  data () {
    return {
      username: '',
      iconUrl: '',
      msg: '',
    } 
  },
  mounted() {
    console.log('user', this.$route);
    this.username = this.$route.params.name || sessionStorage.getItem('isLogin');
    this.iconUrl = this.$route.params.avatar_url || sessionStorage.getItem('iconUrl');
    this.msg = `欢迎你: ${this.username}，这是首页`
  },
  methods: {
    logout() {
      sessionStorage.setItem('isLogin', '');
      this.$router.push('/login')
    }
  }
}
</script>
